<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script type="text/javascript" src="js/vue.js"></script>
</head>
<body>
    
    <div id="root">

        <img :src="src1" style="width: 200px;height: 200px;">
        <button @click="but">点我切换图片</button>

    </div>


</body>

<script>

    vm = new Vue({
        el: '#root',
        data:{
            a:1,
            src1:'img/1.jpg'
            
        },
        methods: {
            but(){
                if(this.a==1){
                    this.src1 = 'img/2.gif';
                    this.a = 0;
                }else{
                    this.src1 = 'img/1.jpg';
                    this.a = 1;
                }
            }
        },
    })

</script>

</html>